<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- 加载 React-->
    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <!-- 引入 babel-->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <title>Counter</title>
</head>
<body>

<div id="app"></div>
<script type="text/babel">

    class App extends React.Component {
        // 构造函数
        constructor(props) {
            super(props);
            this.state = {
                count: 0
            };
        }

        render() {
            return (
                <div>
                    <h1>{this.state.count}</h1>
                    <button onClick={this.count}>Counter</button>
                    The current count is : {this.state.count}
                </div>
            );
        }

        count = () =>{
            this.setState(state => ({
                count: state.count + 1
            }))
        }
    }

    ReactDOM.render(<App/>, document.querySelector('#app'));

</script>
</body>
</html>